package libs.yzx.zaza.acts3;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ListView;

/**
 * Created by Administrator on 2016/10/14
 */
public class InnerListView extends ListView{

    public InnerListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        //如果写在xml里边,可以自定义属性,然后再赋值mHeight(这里没写)
    }

    private int mHeight;

    public InnerListView(Context context,int heigth) {
        super(context);
        mHeight = heigth;
    }




    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        ViewGroup parent = (ViewGroup) getParent();
        setMeasuredDimension(parent.getWidth(),mHeight);

        /* 让listview有几个item就有多高 */
        //int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE/4, MeasureSpec.AT_MOST);
        //super.onMeasure(widthMeasureSpec,heightSpec);

    }

}
